package com.yj.netty.chapter02;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class NettyClientHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        User user = new User();
        user.setName("Tom");
        user.setAge(25);
        String jsonStr = JSONUtil.toJsonStr(user);
        ctx.channel().writeAndFlush(jsonStr);
    }
}
